int x[3] = {1,2,3};
int a = 0;
int b = 1;
int c = 2;
int d = 4;

int temp = x[a];
x[a] = x[b];
x[b] = x[c];
x[c]= temp;

x[2] = d;
x[a] = x[x[a]];
a= x[a]; 